﻿using System.Data.SqlClient;
namespace App_Code
{
    /// <summary>
    ///Product是一个获取数据库字段值的类
    /// </summary>
    public class Product
    {
        public Product(SqlDataReader reader)
        {
            //TODO:有隐患。凭什么reader第1列就是Name？
            Name = reader.GetString(1);
            Description = reader.GetString(4);

            var cp = reader.GetSqlInt32(7);
            if (cp.IsNull)
                CoverPhoto = null;
            else
                CoverPhoto = cp.Value;

            Category = reader.GetString(9);
            Price = reader.GetDecimal(2);
            Discount=reader.GetByte(3);
            Id = reader.GetInt32(0);
        }

        public int Id { get; set; }
        //需要
        public string Name { get; set; }
        //需要
        public decimal Price { get; set; }
        //需要
        public byte Discount { get; set; }
        //需要
        public string Description { get; set; }

        public string Shop { get; set; }

        public short InventoryLevel { get; set; }
        //需要
        public int? CoverPhoto { get; set; }

        public string Category { get; set; }


    }

}